import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index' // 引入vue router
import ElementPlus from 'element-plus' // 引入element plus
import 'element-plus/dist/index.css' // 引入element plus样式
import * as ElementPlusIconsVue from '@element-plus/icons-vue' // 引入element plus图标
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import jagochanConfirm from './utils/jagochanConfirm'
import './permission.ts'
import pinia from './store/store.ts'
import { permission } from './directive/permission.ts'
import hasPerm from './directive/hasPerm'
import * as echarts from 'echarts'

pinia.use(piniaPluginPersistedstate)

const app = createApp(App)
app.use(ElementPlus, {
  locale: zhCn
}).use(pinia).use(router).mount('#app')
// 全局注册图标组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.directive('permission', permission)

app.config.globalProperties.$jagochanConfirm = jagochanConfirm
app.config.globalProperties.$hasPerm = hasPerm
app.config.globalProperties.$echarts = echarts;